# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Sebastien Piccand <sebcactus gmail com>

pkgname=('handbrake' 'handbrake-cli')
pkgver=1.6.1
pkgrel=2
arch=('loong64' 'x86_64')
url="https://handbrake.fr/"
license=('GPL')
_commondeps=('libxml2' 'libass' 'libvorbis' 'opus' 'speex' 'libtheora' 'lame'
             'x264' 'jansson' 'libvpx' 'libva' 'numactl' 'bzip2' 'gcc-libs'
             'zlib' 'xz' 'libjpeg-turbo')
_guideps=('gst-plugins-base' 'gtk3' 'librsvg' 'libgudev')
makedepends=('intltool' 'python' 'nasm' 'wget' 'cmake' 'meson'
             "${_commondeps[@]}" "${_guideps[@]}")
options=('!lto') # https://bugs.archlinux.org/task/72600
source=(https://github.com/HandBrake/HandBrake/releases/download/$pkgver/HandBrake-$pkgver-source.tar.bz2{,.sig})
sha256sums=('94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c'
            'SKIP')
validpgpkeys+=('1629C061B3DDE7EB4AE34B81021DB8B44E4A8645') # HandBrake Team <developers@handbrake.fr>

prepare() {
  cd HandBrake-$pkgver
}

build() {
  cd HandBrake-$pkgver

  ./configure \
    --prefix=/usr \
    --enable-qsv
  make -C build
}

package_handbrake() {
  pkgdesc="Multithreaded video transcoder"
  depends=('desktop-file-utils' 'hicolor-icon-theme'
           "${_commondeps[@]}" "${_guideps[@]}")
  optdepends=('gst-plugins-good: for video previews'
              'gst-libav: for video previews'
              'intel-media-sdk: Intel QuickSync support'
              'libdvdcss: for decoding encrypted DVDs')

  cd HandBrake-$pkgver/build

  make DESTDIR="$pkgdir" install
  rm "$pkgdir/usr/bin/HandBrakeCLI"
}

package_handbrake-cli() {
  pkgdesc="Multithreaded video transcoder (CLI)"
  depends=("${_commondeps[@]}")
  optdepends=('intel-media-sdk: Intel QuickSync support'
              'libdvdcss: for decoding encrypted DVDs')

  cd HandBrake-$pkgver/build
  install -D HandBrakeCLI "$pkgdir/usr/bin/HandBrakeCLI"
}

# vim:set ts=2 sw=2 et:
